<div class="layui-card-body">
    <form class="layui-form" action="{:url()}"  method="post">
        <div class="layui-form-item">
            <label class="layui-form-label">项目名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" value="{$info.title|default=''}" class="layui-input" autocomplete="off"
                       placeholder="不要超过32个汉字">
            </div>
        </div>
<!--        <div class="layui-form-item">-->
<!--            <label class="layui-form-label">项目开始时间</label>-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" name="s_time" value="{$info.s_time|default=''}" class="layui-input"-->
<!--                       autocomplete="off" lay-verify="required" placeholder="" id="s_time" readonly>-->
<!--            </div>-->
<!--            <label class="layui-form-label">项目结束时间</label>-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" name="e_time" value="{$info.e_time|default=''}" class="layui-input"-->
<!--                       autocomplete="off" lay-verify="required" placeholder="" id="e_time" readonly>-->
<!--            </div>-->
<!--        </div>-->
<!--        <div class="layui-form-item">-->

<!--            <label class="layui-form-label">实际时间</label>-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" value="{$info.w_time|default='0'}" class="layui-input"-->
<!--                       autocomplete="off" lay-verify="required" id="w_time" placeholder="单位小时" readonly>-->
<!--            </div>-->
<!--            <label class="layui-form-label">计划时间</label>-->
<!--            <div class="layui-input-inline">-->
<!--                <input type="text" value="{$info.p_time|default='0'}" class="layui-input"-->
<!--                       autocomplete="off" lay-verify="required" id="p_time" placeholder="单位小时" readonly>-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-form-item">
            <label class="layui-form-label">项目状态</label>
            <div class="layui-input-inline">
                <select name="status" lay-search>
                    <volist name="project_status" id="vo" key="k">
                        <option value="{$k}"
                        <notempty name="info.status">
                            <eq name="$k" value="$info.status">selected="selected"</eq>
                        </notempty>
                        > {$vo} </option>
                    </volist>
                </select>
            </div>

        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">详情</label>
            <div class="layui-input-block">
                <div id="info">
                    <p>{$info.info|raw|default=""}</p>
                </div>
                <textarea name="info" id="newinfo" style="display: none">{$info.info|raw|default=""}</textarea>
            </div>
        </div>
        <input type="hidden" name="id" value="{$info.id|default=''}">
        <input type="hidden" name="info_id" value="{$info.info_id|default=''}">
    </form>
</div>
<script type="text/javascript">
    layui.use(['form', 'layer', 'formSelects'], function () {
        var form = layui.form
            , formSelects = layui.formSelects
            , $ = layui.$
            , laydate = layui.laydate;

        laydate.render({
            elem: '#s_time'

        });
        laydate.render({
            elem: '#e_time'

        });
        var E = window.wangEditor
        var editor = new E('#info')
        // 或者 var editor = new E( document.getElementById('editor') )
        editor.customConfig.menus = [
            'head',  // 标题
            'bold',  // 粗体
            'fontSize',  // 字号
            'fontName',  // 字体
            'italic',  // 斜体
            'underline',  // 下划线
            'strikeThrough',  // 删除线
            'foreColor',  // 文字颜色
            'link',  // 插入链接
            'list',  // 列表
            'justify',  // 对齐方式
            'quote',  // 引用
            'image',  // 插入图片
            'table',  // 表格

            'undo',  // 撤销
            'redo'  // 重复
        ]
        editor.customConfig.uploadImgMaxSize = 10 * 1024 * 1024
        editor.customConfig.uploadImgTimeout = 30000
        editor.customConfig.uploadFileName = 'file'
        editor.customConfig.uploadImgServer = '{:url("file/uploadedit",["type"=>"image"])}';
        editor.customConfig.zIndex = 100;
        editor.customConfig.onchange = function (html) {
            $('#newinfo').html(html)
        }
        editor.customConfig.customUploadImg = function (files, insert) {
            var index = layer.load(1);
            $.ajax({
                type: "post",
                url: "/qiniu/gettoken",
                async: true,
                success: function (res) {
                    if (res.code == 0) {
                        var token = res.uptoken;
                        var fileName = res.path + files[0].name;
                        var downloadurl = res.downloadurl;
                        var config = {
                            retryCount: 6,
                        };
                        var putExtra = {
                            fname: "",
                            params: {},
                            mimeType: null
                        };
                        var observable = qiniu.upload(files[0], fileName, token, putExtra, config);
                        var subscription = observable.subscribe(
                            {
                                next(res) {
                                    console.log(res)
                                },
                                error(res) {
                                    console.log(res)
                                },
                                complete(res) {
                                    layer.close(index);
                                    insert(downloadurl + '?file=' + res.key)
                                }
                            }
                        );
                    } else {
                        console.log(res.msg)
                    }

                }
            });
        }
        editor.create()
    });
</script>






